<template>
    <div
        class="daily-contnair"
        v-loading="isLoading"
        element-loading-background="rgba(250, 250, 250, 0.7)"
    >
        <cardComponent pageTitle="按日贷">
            <template slot="cardBody">
                <div class="form-row">
                    <el-form
                        ref="dailyFormRef"
                        :rules="dailyFormRules"
                        :model="dailyForm"
                        label-width="150px"
                        size="small"
                    >
                        <el-row :gutter="25">
                            <el-col :span="12">
                                <el-row>
                                    <el-col :span="24">
                                        <el-form-item label="账户类别 : ">
                                            <el-input disabled v-model="dailyForm.CATEGORY"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="客户姓名 : ">
                                            <el-input disabled v-model="dailyForm.CUSTRNAME"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="证件号码 : ">
                                            <el-input disabled v-model="dailyForm.CUSTID"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="主卡卡号 : ">
                                            <el-input disabled v-model="dailyForm.CARDNBR"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="签约借记卡卡号 : ">
                                            <el-input disabled v-model="dailyForm.CARDNAME"></el-input>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-col>
                            <el-col :span="12">
                                <el-row>
                                    <el-col :span="24">
                                        <el-form-item label="按日贷款额度 : ">
                                            <el-input disabled v-model="dailyForm.CALLIMIT"></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="按日贷款可用额度 : ">
                                            <el-input
                                                class="t-red"
                                                disabled
                                                :value="dailyForm.AVLIMT > dailyForm.CALAVAL ? dailyForm.CALAVAL : dailyForm.AVLIMT"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="按日贷金额 : " prop="LNAMT">
                                            <el-input
                                                minlength="3"
                                                maxlength="8"
                                                v-model="dailyForm.LNAMT"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="按日贷天数 : " prop="LNDAYS">
                                            <el-input
                                                minlength="2"
                                                maxlength="4"
                                                v-model="dailyForm.LNDAYS"
                                            ></el-input>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="24">
                                        <el-form-item label="转入银行卡类型 : " prop="OUTFLAG">
                                            <el-select
                                                v-model="dailyForm.OUTFLAG"
                                                placeholder="请选择转入银行卡类型"
                                                width="100%"
                                            >
                                                <el-option label="无" value></el-option>
                                                <el-option label="本行" value="C"></el-option>
                                                <el-option label="他行" value="X"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-col>
                        </el-row>
                        <el-form-item size="small" label-width="0">
                            <el-button
                                type="primary"
                                size="small"
                                @click="onTrial('dailyFormRef')"
                            >试 算</el-button>
                            <el-button type="primary" size="small" @click="showEditInfor">修改信息</el-button>
                            <!-- 4094贷记卡系统按日贷款申请 -->
                            <el-button
                                type="primary"
                                size="small"
                                @click="onApplyConfirm('dailyFormRef')"
                            >申 请</el-button>
                            <!-- <el-button>关 闭</el-button> -->
                        </el-form-item>
                    </el-form>
                </div>
                <!-- </el-card> -->

                <!-- 试算展示结果窗口 -->
                <el-card shadow="never" v-if="showTrial">
                    <div slot="headerss" class="clearfix">
                        <span style=" padding: 0px 0px 0px 60px;">按日贷试算</span>
                        <el-button
                            style="float: right; padding: 3px 20px;"
                            type="text"
                            @click="showTrial=false"
                        >关 闭</el-button>
                    </div>
                    <el-table
                        :data="trailTable"
                        stripe
                        style="width: 100%; margin: 0 auto;"
                        border
                        class="heard-bg business_table"
                    >
                        <el-table-column prop="LNAMT" label="按日贷款金额" min-width="200"></el-table-column>
                        <el-table-column prop="LNDAYS" label="按日贷款天数" min-width="200"></el-table-column>
                        <el-table-column prop="PAYCFDAY" label="按日贷款到期日" min-width="200"></el-table-column>
                        <el-table-column prop="FEERATE" label="按日贷款息费率" min-width="200"></el-table-column>
                        <el-table-column prop="FEEAMT" label="按日贷款息费" min-width="200"></el-table-column>
                    </el-table>
                </el-card>

                <!-- 修改信息窗口 -->
                <el-dialog
                    v-drag
                    title="按日贷款资料修改"
                    :visible.sync="showEdit"
                    append-to-body
                    @close="closeEdit"
                    center
                    width="500px"
                    :close-on-click-modal="false"
                >
                    <el-form
                        :model="dailyEditForm"
                        :rules="dailyEditRules"
                        ref="dailyEditFormRef"
                        label-width="220px"
                        size="small"
                    >
                        <el-form-item label="账户类别 : ">
                            <el-input
                                disabled
                                v-model="dailyEditForm.CATEGORY"
                                style="width: 200px;"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="主卡卡号 : ">
                            <el-input
                                disabled
                                v-model="dailyEditForm.CARDNBR"
                                style="width: 200px;"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="申请转入的银行卡号 : " prop="OUTCARDNBR">
                            <el-input
                                minlength="18"
                                maxlength="21"
                                v-model.trim="dailyEditForm.OUTCARDNBR"
                                style="width: 200px;"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="申请转入的银行行号 : " prop="OUTBANK">
                            <el-input
                                maxlength="18"
                                v-model.trim="dailyEditForm.OUTBANK"
                                style="width: 200px;"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="申请转入的银行卡银行名称 : " prop="OUTBANKNAME">
                            <el-input
                                maxlength="38"
                                v-model.trim="dailyEditForm.OUTBANKNAME"
                                style="width: 200px;"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="申请转入的银行卡卡片有效期 : " prop="OUTEXP">
                            <el-input
                                minlength="4"
                                maxlength="4"
                                v-model="dailyEditForm.OUTEXP"
                                style="width: 200px;"
                                placeholder="格式 : (MMYY)"
                            ></el-input>
                        </el-form-item>
                        <el-form-item label="申请转入银行卡类型 : " prop="OUTFLAG">
                            <el-select
                                v-model="dailyEditForm.OUTFLAG"
                                placeholder="请选择转入银行卡类型"
                                style="width: 200px;"
                            >
                                <el-option label="无" value></el-option>
                                <el-option label="本行" value="C"></el-option>
                                <el-option label="他行" value="X"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button
                            size="small"
                            icon="el-icon-circle-close"
                            @click="showEdit = false"
                        >取 消</el-button>
                        <el-button
                            type="primary"
                            size="small"
                            @click="onEditInfor('dailyEditFormRef')"
                            icon="el-icon-circle-check"
                            v-preventReClick
                        >确定</el-button>
                    </div>
                </el-dialog>

                <!-- 申请确定窗口 -->
                <el-dialog
                    v-drag
                    title="按日贷款申请信息确定"
                    :visible="showApplyConfirm"
                    :show-close="false"
                    append-to-body
                    center
                    :close-on-click-modal="false"
                    width="500px"
                >
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>卡号:</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{dailyForm.CARDNBR || '' }}</span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>卡产品 :</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{productName || '' }}</span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>签约借记卡卡号 :</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{dailyForm.CARDNAME || '' }}</span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>按日贷金额 :</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{dailyForm.LNAMT || '' }}</span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>按日贷天数 :</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{dailyForm.LNDAYS || '' }}</span>
                        </el-col>
                    </el-row>
                    <el-row :gutter="15">
                        <el-col :span="12" style="text-align: right">
                            <span>转入银行卡类型 :</span>
                        </el-col>
                        <el-col :span="12">
                            <span>{{dailyForm.OUTFLAG === "C" ? "本行" : "他行"}}</span>
                        </el-col>
                    </el-row>

                    <div slot="footer" class="dialog-footer">
                        <el-button
                            size="small"
                            icon="el-icon-circle-close"
                            @click="onApplyDaily('0')"
                        >取 消</el-button>
                        <el-button
                            type="primary"
                            size="small"
                            @click="onApplyDaily('1')"
                            icon="el-icon-circle-check"
                        >确定</el-button>
                    </div>
                </el-dialog>

                <!-- 申请成功返回提示 -->
                <ConfirmWindow v-if="showApplydaily" @isShow="close" :dataList="ApplydailyForm" />
                <!-- <el-dialog v-drag
          title="按日贷款申请成功！"
          :visible.sync="showApplydaily"
          :show-close="false"
          append-to-body
          center
          width="500px"
        >
          <el-form :model="ApplydailyForm" label-width="180px" size="small">
            <el-form-item label="按日贷款金额 : ">
              <el-input disabled v-model="ApplydailyForm.LNAMT" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item label="	按日贷款天数 : ">
              <el-input disabled v-model="ApplydailyForm.LNDAYS" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item label="按日贷款到期日 : ">
              <el-input disabled v-model="ApplydailyForm.PAYCFDAY" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item label="按日贷款息费率 : ">
              <el-input disabled v-model="ApplydailyForm.FEERATE" style="width: 200px;"></el-input>
            </el-form-item>
            <el-form-item label="按日贷款息费 : ">
              <el-input disabled v-model="ApplydailyForm.FEEAMT" style="width: 200px;"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary"  size="small" @click="showApplydaily=false"size="small" icon="el-icon-circle-check" >确定</el-button>
          </div>
                </el-dialog>-->
            </template>
        </cardComponent>
    </div>
</template>

<script>
import { mapState } from 'vuex';
import moment from 'moment';
import cardComponent from '@/components/cardComponent/cardComponent.vue';
import ConfirmWindow from '@/components/ConfirmWindow/ConfirmWindow.vue';
import { get_3xxx, get_4xxx, get_FQxx } from '@/apis/getAPIClass';
import { setNumber, tbBudgetRequisi } from '@/utils/Object';
import { getDictValue, getDictMappingValue } from '@/utils/Common';
import { RegConfig } from '@/utils/RegConfig';

export default {
    name: 'daliy',
    // 混入的调用
    mixins: [modules],
    data() {
        return {
            dailyForm: {
                CATEGORY: '', // 3052
                CUSTRNAME: '', // 3052
                CUSTID: '', // 3052
                CARDNBR: '', // 3001
                CARDNAME: '', // 3052
                CALLIMIT: '', // 3001
                AVLIMT: '', // 3001
                LNAMT: '',
                LNDAYS: '',
                OUTFLAG: undefined,
            },
            productName: '',
            dailyEditForm: {
                CATEGORY: '',
                CARDNBR: '',
                OUTCARDNBR: '',
                OUTBANK: '',
                OUTBANKNAME: '',
                OUTEXP: '',
                OUTFLAG: '',
            },
            trailTable: [
                {
                    LNAMT: '0',
                    LNDAYS: '0',
                    PAYCFDAY: '0',
                    FEERATE: '0',
                    FEEAMT: '0',
                },
            ],
            dailyFormRules: {
                LNAMT: [
                    {
                        required: true,
                        message: '请输入正确的分期金额！',
                        trigger: 'blur',
                    },
                    {
                        validator: (rule, value, callback) => {
                            if (parseInt(value, 10) % 100 != 0) {
                                callback(new Error('输入金额只能是整百的！'));
                            } else {
                                callback();
                            }
                        },
                        trigger: 'blur',
                    },
                    {
                        validator: (rule, value, callback) => {
                            if (value < 200 || value > 50000) {
                                callback(new Error('输入金额应该在200-50000！'));
                            } else {
                                callback();
                            }
                        },
                        trigger: 'blur',
                    },
                ],
                LNDAYS: [
                    {
                        required: true,
                        message: '请输入正确的分期天数！',
                        trigger: 'blur',
                    },
                    {
                        validator: (rule, value, callback) => {
                            if (value < 10) {
                                callback(new Error('按日贷款天数应在10天以上！'));
                            } else {
                                callback();
                            }
                        },
                        trigger: 'blur',
                    },
                ],
                OUTFLAG: [
                    { required: true, message: '请选择转入银行卡类型', trigger: 'change' },
                ],
            },
            dailyEditRules: {
                OUTCARDNBR: [
                    {
                        required: true,
                        message: '请输入转入银行卡号！',
                        trigger: 'blur',
                    },
                    {
                        validator: (rule, value, callback) => {
                            if (!RegConfig.cardNo.test(value)) {
                                callback(new Error('请输入正确卡号！'));
                            } else {
                                callback();
                            }
                        },
                        trigger: 'blur',
                    },
                ],
                OUTBANK: [
                    {
                        required: true,
                        message: '请输入转入银行行号！',
                        trigger: 'blur',
                    },
                ],
                OUTBANKNAME: [
                    {
                        required: true,
                        message: '请输入转入银行名称！',
                        trigger: 'blur',
                    },
                ],
                OUTEXP: [
                    {
                        required: true,
                        message: '请输入转入银行卡有效期！',
                        trigger: 'blur',
                    },
                    {
                        validator: (rule, value, callback) => {
                            if (!/^[0-9]{4}$/.test(value)) {
                                callback(new Error('请输入格式为(MMYY)四位数字日期！'));
                            } else {
                                callback();
                            }
                        },
                        trigger: 'blur',
                    },
                ],
                OUTFLAG: [
                    { required: true, message: '请选择转入银行卡类型', trigger: 'change' },
                ],
            },
            ApplydailyForm: [],
            showApplydaily: false,
            showTrial: false,
            showEdit: false,
            isLoading: false,
            showTrialTable: false,
            showApplyConfirm: false,
            // useInfo: null,
        };
    },
    components: {
        cardComponent,
        ConfirmWindow,
    },
    async mounted() {
        // 获取账户类别
        this.dailyForm.CATEGORY = await getDictMappingValue('CATE', this.cardInfo_3004.CATEGORY, this) || this.cardInfo_3004.CATEGORY;
        // 获取卡产品名字
        this.productName = await getDictValue(
            this.cardList_3601,
            this.cardInfo_3004.CARDNO,
            'PRODUCT',
            this,
        );
        this.onLoadOBJ();
    },
    computed: mapState({
        defaultParams: state => state.common.defaultParams, // 接口默认参数
        cardInfo_3004: state => state.common.cardInfo_3004,
        cardList_3601: state => state.common.cardList_3601,
        inlineParams: state => state.common.inlineParams, // 卡系统交易请求报文,
        pinFlag: state => state.common.pinFlag, // 是否密码检查标志
    }),
    methods: {
        // 页面加载获取页面数据请求_3052_3001请求
        async onLoadOBJ() {
            this.dailyForm.CARDNBR = this.cardInfo_3004.CARDNO;
            this.isLoading = true;
            // 3052 配置请求头
            const appBody_3052 = {
                CARDNBR: this.dailyForm.CARDNBR || '', // 卡号,
                PINFLAG: this.pinFlag,
                INQOPT: 1,
            };
            // 3001 配置请求头
            const appBody_3001 = {
                CARDNO: this.dailyForm.CARDNBR || '',
                PINFLAG: this.pinFlag,
            };
            // 发送_3052_3001请求
            const result_3052 = await get_3xxx(
                '3052',
                '按日贷52',
                appBody_3052,
                this,
                false,
            );
            const result_3001 = await get_3xxx('3001', '按日贷', appBody_3001, this);
            if (!result_3052) return false;
            if (result_3052.sysHead.rspCd === '000000') {
                this.dailyForm.CARDNAME = result_3052.body.appBody.CARDNAME;
                this.dailyForm.CUSTRNAME = result_3052.body.appBody.CUSTRNAME;
                this.dailyForm.BANKNO = result_3052.body.appBody.BANKNO;
                this.dailyForm.CUSTID = result_3052.body.appBody.CUSTID;
                this.dailyEditForm.OUTCARDNBR = result_3052.body.appBody.CARDNAME.trim() || '';
                this.dailyEditForm.OUTBANK = (`${result_3052.body.appBody.BANKNO}`).trim() || '';
                this.dailyEditForm.OUTBANKNAME = result_3052.body.appBody.CARDBANK.trim() || '';
                this.dailyEditForm.OUTEXP = (`${result_3052.body.appBody.CARDEXP}`).trim() || '';
            }
            if (result_3001.sysHead.rspCd === '000000') {
                this.dailyForm.CALIMIT = result_3001.body.appBody.CALIMIT;
                this.dailyForm.CALAVAL = result_3001.body.appBody.CALAVAL;
                this.dailyForm.AVLIMT = result_3001.body.appBody.AVLIMT;
                this.dailyForm.CALLIMIT = result_3001.body.appBody.CALLIMIT;
            }
            this.isLoading = false;
        },
        // 试算请求 4094 请求
        onTrial(ref) {
            this.isLoading = true;
            this.$refs[ref].validate(async (valid) => {
                const PLANID = '1011'; // 改变转入银行卡类型
                const LNAMT = setNumber(this.dailyForm.LNAMT);
                if (valid) {
                    // if (this.dailyForm.OUTFLAG === "C") {
                    //   PLANID = "1012";
                    //   // 请求行内接口
                    //   this.$alert("需要连接到行内接口 FQ02 查询", "接口提示", {
                    //     confirmButtonText: "确定"
                    //   });
                    //   this.isLoading = false;
                    // } else {
                    // 请求他行接口
                    // 4094 配置请求头
                    //
                    if (this.logMixins) {
                        this.logMixins();
                    }
                    const appBody_4094 = {
                        CARDNBR: this.dailyForm.CARDNBR,
                        OPTION: 1,
                        PINFLAG: this.pinFlag,
                        LNAMT,
                        LNDAYS: this.dailyForm.LNDAYS,
                        PLANID,
                    };
                    // 发送_4094请求 //   数据存在 resultData.body.appBody
                    const result_4094 = await get_4xxx(
                        '4094',
                        '按日贷试算',
                        appBody_4094,
                        this,
                    );
                    console.log(result_4094);
                    if (!result_4094) return false;
                    this.trailTable[0].LNAMT = result_4094.body.appBody.LNAMT;
                    this.trailTable[0].LNDAYS = result_4094.body.appBody.LNDAYS;
                    this.trailTable[0].PAYCFDAY = moment(
                        `${result_4094.body.appBody.PAYCFDAY}`,
                    ).format('YYYY-MM-DD');
                    this.trailTable[0].FEERATE = result_4094.body.appBody.FEERATE;
                    this.trailTable[0].FEEAMT = result_4094.body.appBody.FEEAMT;
                    this.showTrial = true;
                    // }
                } else {
                    this.$message.error('验证错误，请核实填写数据！');
                    return false;
                }
            });
            this.isLoading = false;
        },
        // 展示 按日贷款资料修改 弹窗
        showEditInfor() {
            this.dailyEditForm.CATEGORY = this.dailyForm.CATEGORY;
            this.dailyEditForm.CARDNBR = this.dailyForm.CARDNBR;
            this.showEdit = true;
        },
        // 按日贷款资料修改 4075 请求
        onEditInfor(ref) {
            this.$refs[ref].validate(async (valid) => {
                if (valid) {
                    // console.log(this.handleVerifyCard(this.dailyEditForm.OUTCARDNBR))
                    this.handleVerifyCard(this.dailyEditForm.OUTCARDNBR);
                } else {
                    this.$message.error('请根据提示填写数据！');
                    return false;
                }
            });
        },
        async handleTrans() {
            const confirmResult = await this.$confirm(
                '此操作将对按日贷款资料修改, 是否继续?',
                '按日贷款资料修提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    customClass: 'warning', type: 'warning',
                },
            ).catch(err => err);
            if (confirmResult !== 'confirm') return this.$message.info('已取消修改');

            // 4075 配置请求头
            const appBody_4075 = {
                CARDNBR: this.dailyEditForm.CARDNBR || '',
                OPERTP: 0,
                MPDRTYN: 0,
                BTYPE: 0,
                OUTCARDNBR: this.dailyEditForm.OUTCARDNBR,
                OUTBANK: this.dailyEditForm.OUTBANK,
                OUTBANKNAME: this.dailyEditForm.OUTBANKNAME,
                OUTEXP: this.dailyEditForm.OUTEXP,
                OUTFLAG: this.dailyEditForm.OUTFLAG,
            };
            // 发送 4075 接口
            const result_4075 = await get_4xxx(
                '4075',
                '按日贷修改',
                appBody_4075,
                this,
            );
            console.log(result_4075);
            if (!result_4075) return false;
            this.showEdit = false;
            this.$alert(
                `成功代码：${result_4075.sysHead.rspCd}，信息：${result_4075.sysHead.rspMsg}`,
                '按日贷修改操作！',
                {
                    confirmButtonText: '确定',
                    center: true,
                    customClass: 'success', type: 'success',
                    showClose: false,
                },
            );
        },
        // 展示 按日贷款申请确定 弹窗
        onApplyConfirm(ref) {
            this.$refs[ref].validate((valid) => {
                if (valid) {
                    this.showApplyConfirm = true;
                }
            });
        },
        // 按日贷款申请请求
        async onApplyDaily(a) {
            // let tbBudgetRequisiData1 = JSON.parse(JSON.stringify(tbBudgetRequisi));
            // console.log(tbBudgetRequisiData1)
            // const resss1 = await this.$post.businessStatistics.addTbBudgetRe(tbBudgetRequisiData1);
            // console.log(resss1)
            let res = {};
            this.isLoading = true;
            this.showApplyConfirm = false;
            if (a === '0') {
                this.showApplyConfirm = false;
                this.isLoading = false;
                return this.$message.info('已取消申请');
            }
            let PLANID = '1011'; // 改变转入银行卡类型
            const LNAMT = this.dailyForm.LNAMT * 100;
            if (this.dailyForm.OUTFLAG === 'C') {
                PLANID = '1012';
                // 请求行内接口
                const appBody_FQ02 = {
                    CARDNBR: this.dailyForm.CARDNBR,
                    OUTCARD: this.dailyForm.CARDNAME, // 申请转入的银行卡卡号借记卡卡号
                    OUTBANKNAME: this.dailyEditForm.OUTBANKNAME, // 申请转入的银行卡银行名称
                    OPTION: 0, // 0/空格：申请  1：试算
                    SOURCE: 'AG', // 交易来源
                    PINFLAG: '0010',
                    LNRATE: 0,
                    LNAMT,
                    LNDAYS: this.dailyForm.LNDAYS,
                    PLANID,
                };
                console.log(appBody_FQ02);
                // 发送_FQ02请求 //   数据存在 resultData.body.appBody
                const result_FQ02 = await get_FQxx(
                    'FQ02',
                    '按日贷申请',
                    appBody_FQ02,
                    this,
                );
                console.log(result_FQ02);
                if (!result_FQ02) return false;
                result_FQ02.body.appBody.PAYCFDAY = moment(
                    `${result_FQ02.body.appBody.PAYCFDAY}`,
                ).format('YYYY-MM-DD');
                res = result_FQ02.body.appBody;
                // this.ApplydailyForm = { ...result_FQ02.body.appBody };

                //   this.ApplydailyForm = [
                //     {keys: "按日贷款金额 : ", values:"20"},
                //     {keys: "按日贷款天数 : ", values:"201"},
                //     {keys: "按日贷款到期日 : ", values:"20"},
                //     {keys: "按日贷款息费率 : ", values:"20"},
                //     {keys: "按日贷款息费 : ", values:"20"}
                // ]
                // this.$refs.dailyFormRef.resetFields();
                // this.showApplydaily = true;
            } else {
                // 请求他行接口
                // 4094 配置请求头
                const appBody_4094 = {
                    CARDNBR: this.dailyForm.CARDNBR,
                    OPTION: 0, // 0/空格：申请  1：试算
                    PINFLAG: this.pinFlag,
                    LNAMT,
                    LNDAYS: this.dailyForm.LNDAYS,
                    PLANID,
                };
                // 发送_4094请求 //   数据存在 resultData.body.appBody
                const result_4094 = await get_4xxx(
                    '4094',
                    '按日贷申请',
                    appBody_4094,
                    this,
                );
                // console.log(result_4094);
                if (!result_4094) return false;
                result_4094.body.appBody.PAYCFDAY = moment(
                    `${result_4094.body.appBody.PAYCFDAY}`,
                ).format('YYYY-MM-DD');
                res = result_4094.body.appBody;

                // this.ApplydailyForm = { ...result_4094.body.appBody };
                // this.$refs.dailyFormRef.resetFields();
                // this.showApplydaily = true;
            }
            this.ApplydailyForm = [
                { keys: '按日贷款金额 : ', values: res.LNAMT },
                { keys: '按日贷款天数 : ', values: res.LNDAYS },
                { keys: '按日贷款到期日 : ', values: res.PAYCFDAY },
                { keys: '按日贷款息费率 : ', values: res.FEERATE },
                { keys: '按日贷款息费 : ', values: res.FEEAMT },
            ];

            console.log(this.defaultParams);
            // console.log(result_4094);
            // 发送新增分期申请记录 tbBudgetRequisi
            const tbBudgetRequisiData = JSON.parse(JSON.stringify(tbBudgetRequisi));
            tbBudgetRequisiData.agentid = this.defaultParams.body.appHead.opeNo;
            tbBudgetRequisiData.allcountfee = res.FEEAMT;
            tbBudgetRequisiData.banknum = this.defaultParams.body.appHead.bnknbr;
            tbBudgetRequisiData.budgettype = res.OPTION;
            tbBudgetRequisiData.custid = res.CUSTID;
            tbBudgetRequisiData.custname = this.cardInfo_3004.NAME;
            tbBudgetRequisiData.custno = res.CARDNBR;
            tbBudgetRequisiData.instalamt = res.LNAMT;
            tbBudgetRequisiData.jzrate = res.FEERATE;
            tbBudgetRequisiData.planno = res.PLANID;
            tbBudgetRequisiData.retcode = '000000';
            tbBudgetRequisiData.monthnbr = res.LNDAYS;

            console.log(tbBudgetRequisiData);
            try {
                const resss = await this.$post.businessStatistics.addTbBudgetRe(tbBudgetRequisiData);
                console.log(resss);
            } catch (error) {
                console.warn(error);
            }
            this.$refs.dailyFormRef.resetFields();
            this.showApplydaily = true;
            this.showTrial = false;
            this.isLoading = false;
        },
        // 借记卡验证
        handleVerifyCard(cardno) {
            const params = {
                cardno,
            };
            this.$post.common.verifyDebitCard(params).then((res) => {
                if (res.status === 200) {
                    console.log(res.data, '返回结果');
                    if (res.data.iscardbin) {
                        // 校验通过
                        this.handleTrans();
                    } else {
                        // 借记卡校验失败
                        this.$alert(res.data.msg || '借记卡校验失败', '提示', {
                            customClass: 'error', type: 'error',
                        });
                    }
                }
            });
        },
        closeEdit() {
            this.$refs.dailyEditFormRef.resetFields();
        },
        close(data) {
            this.showApplydaily = data;
        },
    },
};
</script>

<style  scoped lang="scss">
.daily-contnair {
    /deep/.el-card__header {
        padding: 8px !important;
    }
    .form-row {
        width: 900px;
        margin: 0 auto;
        .el-select {
            width: 100%;
            // margin-bottom: 15px;
        }
    }
    .el-form-item {
        text-align: center;
        // margin-bottom: 10px;
    }
}
</style>
